package day04.Polymorphic;

public class Test {
    public static void main(String[] args) {
        FeedAnimal(new Cat());
        FeedAnimal(new Dog());


    }

    public static void FeedAnimal(Animal animal){
        animal.show();

        if (animal instanceof Cat){
            Cat cat= (Cat) animal;
            cat.cry();
        }

    }
}
abstract class Animal{
    public abstract void show();
}

class Cat extends Animal {
    public void show(){
        System.out.println("猫真的不爱吃鱼");
    }

    public void cry(){
        System.out.println("Meow~ meow~");
    }
}

class Dog extends Animal {
    public void show(){
        System.out.println("狗爱吃骨头吧？？");
    }
}
